1. What is the purpose of an "if" statement in a program?
Correct Answer: B) To take a decision based on a condition
2. Which of the following is a correct syntax for an "if" statement?
Correct Answer: C) if (condition) { statement; }
3. Which of the following is a valid relational operator used in decision statements?
Correct Answer: C) ==
4. What will happen if the condition in an "if" statement evaluates to false?
Correct Answer: C) The "else" block will execute (if it exists)
5. Which logical operator is used to check if both conditions are true?
Correct Answer: B) &&
6. Which of the following is an example of an "if-else" statement?
Correct Answer: A) if (condition) { statement; } else { statement; }
7. What will the following code output if the user enters 150?
#include
void main() {
int no;
printf("enter a no");
scanf("%d", &no);
if(no > 100) {
printf("No is >100 ");
printf("\n %d", no);
}
printf("\n End of program");
}
Correct Answer: A) No is >100 150
8. What is the output of the following code if the user enters 3?
#include
void main() {
int no;
printf("enter a no");
scanf("%d", &no);
if(no % 2 == 0) {
printf("No is Even ");
} else {
printf("No is Odd ");
}
printf("\n End of program");
}
Correct Answer: C) No is Odd End of program
9. Which statement can be used to check multiple conditions in a decision-making process?
Correct Answer: A) if...else if...else
10. In a decision statement, what is the purpose of the else block?
Correct Answer: B) To execute if the condition is false
11. Which of the following is a logical operator used in decision statements?
Correct Answer: C) &&
12. What is the significance of parentheses () in an "if" condition?
Correct Answer: B) They contain the condition that will be evaluated
13. What keyword is used to introduce an alternative condition in decision-making statements?
Correct Answer: A) else
14. Which relational operator checks if two values are not equal?
Correct Answer: A) !=
15. What kind of decision-making structure allows for multiple "if" statements one after another?
Correct Answer: B) Else if ladder
16. What is the purpose of using multiple if conditions?
Correct Answer: A) To handle more than two conditions
17. Is there a limit on the number of if conditions in a multiple if structure?
Correct Answer: B) No, there is no limit
18. How many blocks of statements are executed in a multiple if structure?
Correct Answer: A) One block of statements
19. What happens if the first condition in an if-else if structure is true?
Correct Answer: B) The rest of the conditions are ignored
20. In the following code, what will be the output if a = 5, b = 10, and c = 3?
if(a > b && a > c)
printf("a is Largest number");
else if(b > a && b > c)
printf("b is Largest number");
else
printf("c is Largest number");
Correct Answer: B) b is Largest number
21. What is the meaning of "nested if" statements?
Correct Answer: A) One if block inside another if block
22. How many levels of nested if statements can you have?
Correct Answer: C) Unlimited levels
23. In a nested if structure, what happens if the outer if condition is false?
Correct Answer: B) The inner if conditions are ignored
24. What is the syntax of an else if block in C?
Correct Answer: A) else if (condition)
25. What is the output of the following code if x = 7 and y = 5?
if(x > 10)
{
if(y < 5)
printf("Nested if true");
else
printf("Outer if true, inner if false");
}
else
{
printf("Outer if false");
}
Correct Answer: C) Outer if false
25. What is the function of the break keyword in C programming?
Correct Answer: C) To exit from a block like a switch or loop
26. In which programming constructs can the break keyword be used?
Correct Answer: B) Switch case, while loop, do loop, for loop
27. What happens when a break statement is executed within a loop or switch block?
Correct Answer: B) Control moves out of the block
28. What does the continue keyword do in a loop?
Correct Answer: A) Skips the rest of the statements and continues to the next iteration
29. What will happen if the continue statement is executed inside a loop?
Correct Answer: B) Control will skip the rest of the statements and return to the beginning of the loop
30. What is the syntax of the continue statement?
Correct Answer: B) continue;
31. Which of the following keywords are used in a switch statement in C programming?
Correct Answer: B) switch, case, default, break
32. Which of the following data types can be used in a switch expression?
Correct Answer: A) Integer and character values only
33. What is the purpose of the break statement in a switch block?
Correct Answer: B) To exit from the switch block
34. If the switch expression does not match any case value, what will happen if a default statement is present?
Correct Answer: A) The default block will execute
35. What must follow each case value in a switch statement?
Correct Answer: B) Colon :
36. In a switch statement, are case values required to be in a specific order?
Correct Answer: B) No
37. What is a nested switch statement?
Correct Answer: B) A switch block within another switch block
38. In the nested switch example, what happens if the inner switch statement does not have a matching case value?
Correct Answer: B) The default block will execute if present
39. What is the output when no break is provided in a switch case?
Correct Answer: B) All cases below the matched case will also execute
40. What will happen if the break keyword is not used after a case in a switch statement?
Correct Answer: B) All subsequent cases will also execute until a break is encountered